﻿<cfsilent>
	<cfscript>
	
		event.setArg("pageTitle", "课程补考成绩底单");
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		markAdvice = getProperty("serviceFactory").getBean("markAdvice");
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		
		teacherId = sessionAdvice.getAutherUserID();
		
		hashCode = event.getArg("Sign");
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		
		checked = false;
		
		try {
			
			if ( decrypt(hashCode, teacherId, "PBEWithMD5AndDES", "Hex") eq taskId ) {
				
				checked = true;

				/* 载入补考教学任务 */
				
				sql = "SELECT 
							a.term_id,b.course_code,c.institute_name,
							b.course_name,a.cidx,d.academic_year,
							d.academic_term,b.course_credit 
						FROM 
							t_resitplan a 
							INNER JOIN t_course b ON a.cid = b.cid 
							INNER JOIN t_institute c ON b.institute_id = c.institute_id 
							INNER JOIN t_term d ON a.term_id = d.term_id 
						WHERE 
							a.task_id = :taskId ";
							
				queryObj = new query( datasource=application.dnsSlave );
				
				queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
				
				rs_task = queryObj.execute( sql=sql ).getResult();
				
				/*教师姓名*/
				sql = "SELECT 
							tch_name 
						FROM 
							t_teacher 
						WHERE 
							tch_id = :teacherId ";
							
				queryObj = new query( datasource=application.dnsSlave );
				
				queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar");
				
				rs_teacher = queryObj.execute( sql=sql ).getResult();
		
				/* 学校信息 */
				sql = "SELECT 
							sch_name 
						FROM 
							t_school ";
							
				queryObj = new query( datasource=application.dnsSlave );
				
				rs_school = queryObj.execute( sql=sql ).getResult();

		
				/* 成绩数据 */
				sql = "SELECT 
							b.stu_id,b.stu_name,c.cls_name,
							c.grade,a.retaking,a.mark_mode,a.mark_resit,
							a.mark_renote,a.mark_resit_limit 
						FROM 
							t_student_mark a 
							INNER JOIN t_student b ON a.stu_id = b.stu_id 
							INNER JOIN t_class c ON b.cls_id = c.cls_id 
						WHERE 
							a.task_id = :taskId 
							AND 
							a.mark_resit > -1 
						ORDER BY a.stu_id ";
						
				queryObj = new query( datasource=application.dnsSlave);
				
				queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
				
				rs_chooser = queryObj.execute( sql=sql ).getResult();
											
				rowPerPage = 40;
		
				if ( rs_chooser.recordCount mod rowPerPage ) {
					totlePageCount = int(rs_chooser.recordCount/rowPerPage) + 1;
				}
				else {
					totlePageCount = int(rs_chooser.recordCount/rowPerPage);
				}
		
				pageRowBegin = 1;
				pageRowEnd = min(rowPerPage, rs_chooser.recordCount);
		
				tagCode = "CJBD-" & rs_task.term_id & "," & rs_task.course_code & "," & rs_task.cidx;
				
			}
			
		}
		catch (any ecpt) {
		}
	
	</cfscript>
</cfsilent>

<cfif checked >

	<cfloop from="1" to="#totlePageCount#" index="currentPage">

		<cfif currentPage GT 1><div class="page_break"></div></cfif>
		<div class="UIprintableTitle"><cfoutput>海外学院</cfoutput>课程补考成绩单</div>
		<table width="98%" border="0" cellpadding="1" cellspacing="0">
			<tr>
				<td>任课单位 <cfoutput>#rs_task.institute_name#</cfoutput></td>
				<td>教学班 <cfoutput>#rs_task.course_name#</cfoutput>-<cfoutput>#rs_teacher.tch_name#</cfoutput>-<cfoutput>#rs_task.cidx#</cfoutput></td>
				<td>教师 [<cfoutput>#teacherId#</cfoutput>]<cfoutput>#rs_teacher.tch_name#</cfoutput></td>
				<td align="right">成绩记录 <cfoutput>#rs_chooser.recordCount#</cfoutput>条</td>
			</tr>
			<tr>
				<td>学期 <cfoutput>#rs_task.academic_year#</cfoutput>-<cfoutput>#rs_task.academic_term#</cfoutput></td>
				<td>课程 <cfif rs_task.course_code neq "">[<cfoutput>#rs_task.course_code#</cfoutput>]</cfif><cfoutput>#rs_task.course_name#</cfoutput></td>
				<td>学分 <cfoutput>#numberFormat(rs_task.course_credit, "_.__")#</cfoutput></td>
				<td align="right">第<cfoutput>#currentPage#</cfoutput>页 共<cfoutput>#totlePageCount#</cfoutput>页</td>
			</tr>
		</table>
		<table class="UIprintable" width="100%" border="1" cellpadding="5" cellspacing="1">
			<thead>
				<tr>
					<td>序</td>
					<td>学号</td>
					<td>姓名</td>
					<td>班级</td>
					<td>年级</td>
					<td>重修</td>
				
					<td>成绩</td>
				</tr>
			</thead>
			<tbody>
				<cfloop index="row" from="#pageRowBegin#" to="#pageRowEnd#">
					<tr>
						<td><cfoutput>#row#</cfoutput></td>
						<td><cfoutput>#rs_chooser["stu_id"][row]#</cfoutput></td>
						<td><cfoutput>#rs_chooser["stu_name"][row]#</cfoutput></td>
						<td><cfoutput>#rs_chooser["cls_name"][row]#</cfoutput></td>
						<td><cfoutput>#rs_chooser["grade"][row]#</cfoutput></td>
						<td><cfif yesNoFormat(rs_chooser["retaking"][row])>是<cfelse>&nbsp;</cfif></td>
						<td><cfoutput>#markAdvice.getMarkResit( rs_chooser["mark_mode"][row], rs_chooser["mark_resit"][row], rs_chooser["mark_renote"][row], rs_chooser["mark_resit_limit"][row] )#</cfoutput></td>
					</tr>
				</cfloop>
			</tbody>
		</table>
		<div class="clear2px"></div>
		<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<td>打印时间 <cfoutput>#dateFormat(now(), "YYYY年MM月DD日")#</cfoutput></td>
				<td>教师签字</td>
				<td align="right"><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/Print/<cfoutput>#tagCode#</cfoutput>.png" height="43"/></td>
			</tr>
		</table>
	
		<cfset pageRowBegin = pageRowBegin + rowPerPage />
		<cfset pageRowEnd = pageRowEnd + rowPerPage />
		<cfif pageRowEnd gt rs_chooser.recordCount>
			<cfset pageRowEnd = rs_chooser.recordCount />
		</cfif>
	
	</cfloop>

</cfif>